找传奇、传世资源到传世资源站!

简单的音乐播放器(支持wav文件播放)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboardusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Media;using System.IO;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } List<string> listsongs = new List<string>(); SoundPlayer sp = new SoundPlayer(); private void button1_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.Title = "请选择要添加的音乐文件"; of.Filter= @"音乐文件|*.mp3||*.wav|所有文件|*.*"; if (of.ShowDialog() == DialogResult.OK) { string[] pa_th = of.FileNames; for (int i = 0; i < pa_th.Length; i ) { listBox1.Items.Add(Path.GetFileName(pa_th[i])); listsongs.Add(pa_th[i]); } } } private void button3_Click(object sender, EventArgs e) { int Index = listBox1.SelectedIndex; Index ; if (Index == listBox1.Items.Count) { Index = 0; } listBox1.SelectedIndex = Index; sp.SoundLocation = listsongs[Index]; sp.Play(); } private void button2_Click(object sender, EventArgs e) { int Index = listBox1.SelectedIndex; Index--; if (Index < 0) { Index = listBox1.Items.Count - 1; } listBox1.SelectedIndex = Index; sp.SoundLocation = listsongs[Index]; sp.Play(); } private void listBox1_DoubleClick(object sender, EventArgs e) { SoundPlayer sp1 = new SoundPlayer(); sp1.SoundLocation = listsongs[listBox1.SelectedIndex]; sp1.Play(); } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复